const express = require('express');
const favoriteNameController = require('./../controllers/favoriteNameController');
const authController = require('./../controllers/authController');
const router = express.Router({ mergeParams: true });
// '/users/:userId(234fad4)/favorites/94887fda',
// P0ST /users/234fad4/favorites
// GET /users/234fad4/favorites
//GET /users/234fad4/favorites/94887fda
router.use(authController.protect);
router.route('/').get(favoriteNameController.getAllFavoriteNames).post(
  // authController.restrictTo('user'),
  favoriteNameController.setUserUserId,
  favoriteNameController.createFavorite
);
//fetch my favorList
router
  .route('/getMyFavor')
  .get(
    favoriteNameController.setUserUserId,
    favoriteNameController.findUserFavorites
  );
//add video into favorList
router
  .route('/addFavoriteNameIntoList')

  .post(
    favoriteNameController.setUserUserId,
    favoriteNameController.addVideoToFavorite
  );
router
  .route('/:id')
  .get(favoriteNameController.getFavoriteName)
  .patch(
    // authController.restrictTo('user', 'admin'),
    favoriteNameController.updateFavoriteName
  )
  .delete(
    // authController.restrictTo('user', 'admin'),
    favoriteNameController.deleteFavoriteName
  );
module.exports = router;
